/**
 * 
 */
package com.woniuxy.amusementparkos.permission.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.woniuxy.amusementparkos.entity.fzw.Department;
import com.woniuxy.amusementparkos.permission.Service.DepartmentService;
import com.woniuxy.amusementparkos.util.lzw.result.ResponseResult;

/**
 *
 * @author fzw
 *
 * 2020年4月29日
 */
@Controller
public class DepartmentController {
	//自动注入
	@Autowired
	DepartmentService departmentService;
	
	@RequestMapping("/department/selectAll")
	@ResponseBody
	public ResponseResult<List<Department>> selectAllDepartment(){
		//初始值
		ResponseResult<List<Department>> result = new ResponseResult<List<Department>>(404,"服务器错误！",null);
		
		try {
				//查询所有部门
			List<Department> departments=departmentService.selectAllDepartment();
				//没有异常则设置
			result.setData(departments);
		} catch (RuntimeException e) {
			result.setCode(4);
			result.setMsg("查询失败！请联系工作人员！");
			return result;
		}catch (Exception e) {
			result.setCode(4);
			result.setMsg("系统错误！");
			return result;
		}
		result.setCode(200);
		result.setMsg("查询所有部门成功！");
		return result;
	}
}
